package com.mitei.ihm.composite;

import java.awt.GridLayout;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.Border;

import com.mitei.ihm.messages.Messages;

public class IHMOptionsPosition extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String [] options = {"Fs", "Move 1", "Move 2", "Move 3", "Move 4", "Pos 1", "Pos 2", "Bord", "Shad"};
	private ArrayList<JLabel> labels = null;
	private ArrayList<JTextField> textFields = null;
	private GridLayout gridLayout = null;
	
	public IHMOptionsPosition() {
		this.gridLayout = new GridLayout(this.options.length, 2);
		this.setLayout(gridLayout);		
		this.labels = new ArrayList<JLabel>();
		this.textFields = new ArrayList<JTextField>();
		for(int i = 0 ; i < options.length ; i++) {
			this.labels.add(new JLabel(options[i]));
			this.textFields.add(new JTextField());
			this.add(this.labels.get(i));
			this.add(this.textFields.get(i));
		}
		Border etched = BorderFactory.createEtchedBorder();
		Border titled = BorderFactory.createTitledBorder(etched, Messages.OPTIONS_DE_POSITION);
		setBorder(titled);
	}

	public String getOptionByName(String optionName) {
		for(int i = 0 ; i < this.options.length ; i++) {
			if(this.options[i].toUpperCase().equals(optionName.toUpperCase())) {
				return this.textFields.get(i).getText();
			}
		}
		return null;
	}
	
	public String[] getOptions() {
		return options;
	}

	public void setOptions(String[] options) {
		this.options = options;
	}

	public ArrayList<JTextField> getTextFields() {
		return textFields;
	}

	public void setTextFields(ArrayList<JTextField> textFields) {
		this.textFields = textFields;
	}
}
